//
//  CZForwardTextView.swift
//  GZWeibo007
//
//  Created by shiying on 15/12/24.
//  Copyright © 2015年 Apple. All rights reserved.
//

import UIKit

import SVProgressHUD

class CZForwardTextView: UITextView {

  /*  var status: CZStatus? {
        didSet {
            if let forwardStatus = status?.retweeted_status {
                let text = "@\(forwardStatus.user!.screen_name!):\(forwardStatus.text)"
                placeholder = text
            }
        }
    }*/

    var placeholder: String! {
        didSet {  
            placeholderLabel.text = placeholder
        
        }
    }

    override init(frame: CGRect, textContainer: NSTextContainer?) {
        super.init(frame: frame, textContainer: textContainer)
        
        self.addSubview(placeholderLabel)
        placeholderLabel.textColor = UIColor.blackColor()
        
        NSNotificationCenter.defaultCenter().addObserver(self, selector: "placeholderLabelChange", name: UITextViewTextDidChangeNotification, object: nil)
    }
    
    deinit {
        NSNotificationCenter.defaultCenter().removeObserver(self)
    }
    
    func placeholderLabelChange() {
        placeholderLabel.hidden = hasText()
        
    }
 
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
   

    lazy var placeholderLabel: UILabel = {
        let label = UILabel(frame: CGRect(x: 0, y: 5,  width: CGFloat(UIScreen.mainScreen().bounds.size.width) - 10, height: 200));
    
        label.font = UIFont.systemFontOfSize(15)
        label.textColor = UIColor.redColor()
//        label.text = "转发微博"
        label.sizeToFit()
        return label
    }()
}
